<template>
	<view class="main-box">
		<view class="navigator-bar" :style="{'padding-top': safeTop + 'px'}">
			<image class="back-img" src="/static/backArrow2.png" @click="back()"></image>
			<view class="tab-box">
				<view :class="index === 0 ? 'choose-tab': 'unchoose-tab'" @click="changeIndex(0)">
					<text>粉丝</text>
					<view :class="index === 0 ? 'choose-box': 'unchoose-box'"></view>
				</view>
				<view :class="index === 1 ? 'choose-tab': 'unchoose-tab'" @click="changeIndex(1)">
					<text>点赞</text>
					<view :class="index === 1 ? 'choose-box': 'unchoose-box'"></view>
				</view>
				<view :class="index === 2 ? 'choose-tab': 'unchoose-tab'" @click="changeIndex(2)">
					<text>评论</text>
					<view :class="index === 2 ? 'choose-box': 'unchoose-box'"></view>
				</view>
			</view>
		</view>
		<swiper class="index-swiper-box" :indicator-dots="false" :current="index" disable-touch="true" :duration="0" :style="{'height': `calc(100vh - ${safeTop}px - 86rpx)`}">
			<swiper-item>
				<scroll-view class="notice-list" scroll-y="true">
					<view class="fans-item" v-for="notice of fansNotice">
						<view class="avatar-box" @click="jumpToUserInfo(notice.fromId)">
							<image class="avatar-img" :src="notice.fromAvatar"></image>
							<image class="sex-img" src="/static/portraitTagGirl-s.png"></image>
						</view>
						<view class="info-box">
							<view class="name-row">
								<view>
									<text class="name-text">{{ notice.fromName }}</text>
									<text class="status-text">关注了你</text>
								</view>
							</view>
							<view class="time-row">{{ notice.createTime }}</view>
						</view>
						<view class="control-button">关注</view>
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<scroll-view class="notice-list" scroll-y="true">
					<view class="like-item" v-for="notice of likeNotice">
						<view class="avatar-box" @click="jumpToUserInfo(notice.fromId)">
							<image class="avatar-img" :src="notice.fromAvatar"></image>
							<image class="sex-img" src="/static/portraitTagGirl-s.png"></image>
						</view>
						<view class="info-box">
							<view class="name-row">
								<view>
									<text class="name-text">{{ notice.fromName }}</text>
									<text class="status-text">点赞了</text>
								</view>
								<view class="time-text">{{ notice.createTime }}</view>
							</view>
							<view class="dynamic-row">动态】随便写写突然就写突然就有很多灵感你有很多灵感你...
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
			<swiper-item>
				<scroll-view class="notice-list" scroll-y="true">
					<view class="like-item"  v-for="notice of commentNotice">
						<view class="avatar-box" @click="jumpToUserInfo(notice.fromId)">
							<image class="avatar-img" :src="notice.fromAvatar"></image>
							<image class="sex-img" src="/static/portraitTagGirl-s.png"></image>
						</view>
						<view class="info-box">
							<view class="name-row">
								<view>
									<text class="name-text">{{ notice.fromName }}</text>
									<text class="status-text">回复了</text>
								</view>
								<view class="time-text">{{ notice.createTime }}</view>
							</view>
							<view class="comment-text">你说不错，就是这个逻辑</view>
							<view class="dynamic-row">动态】随便写写突然就写突然就有很多灵感你有很多灵感你...
							</view>
						</view>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				safeTop: 0,
				index: 0,
				fansNotice: [],
				likeNotice: [],
				commentNotice: []
			};
		},
		onLoad() {
			this.safeTop = this.$safeTop;
			this.initData();
		},
		methods: {
			jumpToUserInfo(id) {
				uni.navigateTo({
					url: '/pages/userDetai?userId=' + id
				})
			},
			back() {
				uni.navigateBack();
			},
			changeIndex(index) {
				this.index = index;
			},
			initData() {
				this.getFansNotice();
				this.getLikeNotice();
				this.getCommentNotice();
			},
			getFansNotice() {
				const params = {
					pageSize: 50,
					pageNum: this.pageNum,
					type: 2,
					interactType: 0
				}
				this.$apis.getNoticeList(params).then(res => {
					if (res.code === 0) {
						this.fansNotice = res.data.list;
					}
				})
			},
			getLikeNotice() {
				const params = {
					pageSize: 50,
					pageNum: this.pageNum,
					type: 2,
					interactType: 1
				}
				this.$apis.getNoticeList(params).then(res => {
					if (res.code === 0) {
						this.likeNotice = res.data.list;
					}
				})
			},
			getCommentNotice() {
				const params = {
					pageSize: 50,
					pageNum: this.pageNum,
					type: 2,
					interactType: 2
				}
				this.$apis.getNoticeList(params).then(res => {
					if (res.code === 0) {
						this.commentNotice = res.data.list;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.main-box {
		width: 100vw;
		height: 100vh;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		overflow: hidden;

		.navigator-bar {
			width: 100vw;
			height: 86rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			position: relative;

			.back-img {
				width: 24rpx;
				height: 40rpx;
				margin-left: 42rpx;
				z-index: 999;
			}

			.page-title {
				font-size: 38rpx;
				font-weight: bold;
				color: #222222;
				position: absolute;
				width: 100vw;
				line-height: 38rpx;
				text-align: center;
			}

			.tab-box {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				position: absolute;

				.choose-tab {
					font-size: 40rpx;
					font-weight: bold;
					color: #222222;
					display: flex;
					flex-direction: column;
					align-items: center;
					padding: 0 25rpx 0 25rpx;
				}

				.unchoose-tab {
					font-size: 32rpx;
					font-weight: 400;
					color: #222222;
					display: flex;
					flex-direction: column;
					align-items: center;
					padding: 0 25rpx 0 25rpx;
				}

				.choose-box {
					width: 40rpx;
					height: 8rpx;
					background: #FF5E2E;
					border-radius: 4rpx;
				}

				.unchoose-box {
					width: 40rpx;
					height: 8rpx;
				}
			}
		}

		.index-swiper-box {
			width: 100%;
			
			.notice-list {
				width: 100%;
				height: 100%;
				
				.avatar-box {
					width: 80rpx;
					height: 80rpx;
					margin-left: 32rpx;
					position: relative;
					
					.avatar-img {
						width: 80rpx;
						height: 80rpx;
						border-radius: 80rpx;
					}
					
					.sex-img {
						width: 22rpx;
						height: 22rpx;
						position: absolute;
						bottom: 0;
						right: 0;
					}
				}
				
				.name-row {
					display: flex;
					justify-content: space-between;
					
					.name-text {
						font-size: 28rpx;
						font-weight: bold;
						color: #222222;
						display: inline-block;
					}
					
					.status-text {
						font-size: 28rpx;
						font-weight: 400;
						color: #999999;
						margin-left: 16rpx;
						display: inline-block;
					}
					
					.time-text {
						font-size: 24rpx;
						font-weight: 400;
						color: #999999;
					}
				}
				
				.fans-item {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-top: 48rpx;
					
					.info-box {
						width: 430rpx;
						
						.time-row {
							font-size: 24rpx;
							font-weight: 400;
							color: #999999;
							margin-top: 6rpx;
						}
					}
					
					.control-button {
						width: 112rpx;
						height: 64rpx;
						border-radius: 32rpx;
						border: 2rpx solid #F0F3F6;
						font-size: 28rpx;
						font-weight: 400;
						color: #222222;
						line-height: 64rpx;
						text-align: center;
						margin-right: 32rpx;
					}
				}
			
				.like-item {
					display: flex;
					align-items: flex-start;
					justify-content: space-between;
					padding-top: 48rpx;
					
					.info-box {
						width: 572rpx;
						margin-right: 32rpx;
						padding-top: 20rpx;
						
						.comment-text {
							width: 572rpx;
							font-size: 32rpx;
							font-weight: 400;
							color: #222222;
							margin-top: 16rpx;
						}
						
						.dynamic-row {
							margin-top: 16rpx;
							width: 532rpx;
							font-size: 28rpx;
							font-weight: 400;
							color: #222222;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							background: #F6F7F9;
							border-radius: 20rpx;
							padding: 20rpx 20rpx;
						}
					}
				}
			}
		}
	}
</style>
